package com.xgp.company.创建型模式.第四种_原型模式.demo2;

import java.util.Date;

/**
 * 客户端：克隆
 */
@SuppressWarnings("all")
public class Client {
    /**
     * 演示浅克隆弊端
     * @param args
     * @throws CloneNotSupportedException
     */
    public static void main(String[] args) throws CloneNotSupportedException {
        //原型对象
        Date date = new Date();
        Video v1 = new Video("狂神说java", date);
        System.out.println("v1 = " + v1);
        System.out.println("v1 = " + v1.hashCode());

        //v1 克隆 v2
        Video v2 = (Video) v1.clone();
        System.out.println("v2 = " + v2);
        System.out.println("v2 = " + v2.hashCode());

        System.out.println("========================");

        date.setTime(22222222);
        System.out.println("v1 = " + v1);
        System.out.println("v1 = " + v1.hashCode());

        //v1 克隆 v2
        System.out.println("v2 = " + v2);
        System.out.println("v2 = " + v2.hashCode());

    }

}
